#pragma once
#include <QObject>
#include <iostream>

class InterFace : public QObject
{
    Q_OBJECT

    Q_PROPERTY(int CPP_PageIndex READ GetPageIndex WRITE SetPageIndex NOTIFY SignPageIndexChanged FINAL);
    Q_PROPERTY(int CPP_PrevPageIndex READ GetPrevPageIndex WRITE SetPrevPageIndex NOTIFY SignPrevPageChanged FINAL);
    // CONSTANT：表示该属性是一个常量，值不可更改，因此不需要提供写入方法
    // FINAL：表示该属性是最终的，不能在派生类中重写
    Q_PROPERTY(int CPP_PAGE_SETTING READ GetPageSetting CONSTANT FINAL);
    Q_PROPERTY(int CPP_PAGE_HOME READ GetPageHome CONSTANT FINAL);
    Q_PROPERTY(int CPP_PAGE_PRI READ GetPageRpi CONSTANT FINAL);
    Q_PROPERTY(int CPP_PAGE_TEST READ GetPageTest CONSTANT FINAL);

    const static int PAGE_SETTING = 0;
    const static int PAGE_HOME = 1;
    const static int PAGE_RPI = 2;
    const static int PAGE_TEST = 3;

private:
    explicit InterFace(QObject *parent = nullptr);

public:
    static InterFace *GetInstance();
    ~InterFace();
signals:
    void SignPageIndexChanged();
    void SignPrevPageChanged();

public:
    int GetPageIndex() const;
    void SetPageIndex(const int index);
    int GetPrevPageIndex() const;
    void SetPrevPageIndex(const int index);
    int GetPageSetting() const;
    int GetPageHome() const;
    int GetPageRpi() const;
    int GetPageTest() const;

private:
    static InterFace *m_instance;
    int m_page_index;
    int m_prev_page_index;
};